<template>
  <div class="item">
    <div class="left" @click="goDetail(filmData.filmId)">
      <img v-lazy="filmData.poster" />
    </div>
    <div class="middle">
      <div>{{ filmData.name }}</div>
      <div>
        <span>观众评分</span>
        <span>{{ filmData.grade }}</span>
      </div>
      <div>主演：闫非 彭安宇 宁浩 徐峥 陈思诚</div>
      <div>中国大陆 | 150分钟</div>
    </div>
    <div class="right">
      <span>购票</span>
    </div>
  </div>
</template>

<script>
export default {
  props: ['data'],
  // 计算属性
  computed: {
    filmData() {
      return { ...this.data, grade: this.data.grade || ' 无' }
    }
  },
  methods: {
    goDetail(id) {
      this.$router.push({
        name: 'filmsDetail',
        params: { id }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.item {
  padding-top: 15px;
  padding-bottom: 15px;
  display: flex;
  color: #797d82;
  font-size: 13px;
  .left {
    width: 77px;
    height: 100px;
    img {
      width: 66px;
      height: 100%;
    }
  }

  .middle {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 55%;
    div:nth-of-type(1) {
      color: #191a1b;
      font-size: 16px;
    }

    div:nth-of-type(3) {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
  }

  .right {
    width: 15%;
    display: flex;
    align-items: center;
    margin-right: 20px;
    span {
      border: 1px solid #ff5f16;
      background: white;
      color: #ff5f16;
      border-radius: 2px;
      height: 25px;
      line-height: 25px;
      font-size: 13px;
      width: 50px;
      text-align: center;
    }
  }
}
</style>
